package com.hksj.Intelligentmanagement.controller;

import com.hksj.Intelligentmanagement.common.Result;
import com.hksj.Intelligentmanagement.dto.CallUserDTO;
import com.hksj.Intelligentmanagement.service.CallUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Api(tags = "护工管理")
@RestController
@RequestMapping("/api/porter")
public class CallUserController {
    @Autowired
    private CallUserService porterService;

    @ApiOperation("新增护工信息")
    @PostMapping("/createPorter")
    public Result createPorter(@Valid @RequestBody CallUserDTO callUserDTO) {
        return porterService.createPorter(callUserDTO);
    }

    @ApiOperation("删除护工信息")
    @DeleteMapping("/deletePorter/{id}")
    public Result deletePorter(@PathVariable("id") String id) {
        return porterService.deletePorter(id);
    }

    @ApiOperation("修改护工信息")
    @PutMapping("/updatePorter")
    public Result updatePorter(@Valid @RequestBody CallUserDTO callUserDTO) {
        return porterService.updatePorter(callUserDTO);
    }

    @ApiOperation("根据id查询护工信息")
    @GetMapping("/queryPorterById/{id}")
    public Result queryPorterById(@PathVariable String id) {
        return porterService.queryPorterById(id);
    }

    @ApiOperation("动态分页模糊查询护工信息列表")
    @PostMapping("/queryPorterListByPage")
    public Result queryPorterListByPage(@RequestBody CallUserDTO callUserDTO) {
        return Result.ok(porterService.queryPorterListByPage(callUserDTO));
    }
}
